import requests

# 解压
r = requests.get('https://www.163.com', stream=True)
print(r.headers['Content-Encoding'])
# print(r.raw.read())  #原始的数据
if r.headers['Content-Encoding'] == 'gzip':
    import gzip

    data = gzip.decompress(r.raw.read())
    print(data)

# 压缩
import gzip

data = 'this is test data'
compress_data = gzip.compress(data.encode())
print(len(data))
print(len(compress_data))
print(compress_data)
